package com.example.poc.food;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

public interface FoodRepository extends JpaRepository<Food, Long>, JpaSpecificationExecutor<Food> {

  String FILTER_FOODS_ON_DESCRIPTION_QUERY = "select b from Food b where UPPER(b.description) like CONCAT('%',UPPER(?1),'%')";

  @Query(FILTER_FOODS_ON_DESCRIPTION_QUERY)
  List<Food> findByDescriptionLike(String descriptionFilter);

  @Query(FILTER_FOODS_ON_DESCRIPTION_QUERY)
  Page<Food> findByDescriptionLike(String descriptionFilter, Pageable pageable);

}
